import Vue from 'vue';
import Router from 'vue-router';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
// 简单配置
NProgress.inc(0.2);
NProgress.configure({ easing : 'ease', speed : 500, showSpinner : false });
Vue.use(Router);

let router = new Router({
	routes : [
		{
			path : '/home',
			// eslint-disable-next-line no-undef
			component : () => import(/* webpackChunkName:'home'*/ 'views/Home')
		},
		{
			path : '/found',
			// eslint-disable-next-line no-undef
			component : () => import(/* webpackChunkName:'found'*/ 'views/Found')
		},
		{
			path : '/mine',
			// eslint-disable-next-line no-undef
			component : () => import(/* webpackChunkName:'mine'*/ 'views/Mine')
		},
		{
			path : '/',
			redirect : '/home'
		}
	]
});

router.beforeEach((to, from, next) => {
	NProgress.start();
	let f = false;
	if (to.path !== '/login') {
		if (f) {
			next({
				path : '/login'
			});
			return;
		}
	}
	next();
});

router.afterEach(() => {
	NProgress.done();
});
export default router;
